package com.atguigu.java.ai.langchain4j.Controller;

import com.atguigu.java.ai.langchain4j.assistant.XiaoZhiAssistant;
import com.atguigu.java.ai.langchain4j.bean.ChatForm;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.util.Date;

@RestController
@RequestMapping("/xiaozhi")
public class XiaozhiController {
    @Autowired
    private XiaoZhiAssistant xiaoZhiAssistant;

    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody ChatForm chatForm){
        return xiaoZhiAssistant.chat(chatForm.getMemoryId(), chatForm.getMessage(), new Date());


    }

}
